#include <soar.h>

#define MODULE_NAME "CREATE"

#define	AREA_FILE                "sample_shm_area"

struct rec
{
    int recno;
};


int main(int argc, char *argv[])
{
    char buf[BUFFER_SIZE];
    int result;
    struct rec *rec;

    sprintf(buf, "%s.LOG", MODULE_NAME);
    //trace_stdout(buf);

    if((result=shm_area_create(AREA_FILE, sizeof(struct rec),
                    SHM_AREA_LOCK)))
    {
        printf("%s: shm_area_create fail, result: %d\n",
            __func__, result);
        return(-1);
    }

    if((rec=(struct rec *)shm_area_attach(AREA_FILE)) == NULL)
    {
        printf("%s: shm_area_attach fail, result: %d\n",
            __func__, result);
        return(-1);
    }

    shm_area_enter((void *)rec);
    rec->recno=10000;
    printf("init: recno: %d\n", rec->recno);
    shm_area_leave(rec);

    if((result=shm_area_detach((void *)rec)))
    {
        printf("%s: shm_area_detach fail, result: %d\n",
            __func__, result);
        return(-1);
    }

    return(0);
}
